// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
#include "stdafx.h"

#include "PRTIconMesh.hpp"
#include "PRTLoaderIconMesh.hpp"

using namespace frantic::geometry;

namespace {
float vertices[] = {
    -0.378859f,   0.0f, 0.368268f, -0.381437f,   0.0f, 0.360952f, -0.385642f,    0.0f, 0.354901f,
    -0.391385f,   0.0f, 0.350044f, -0.397217f,   0.0f, 0.346946f, -0.403865f,    0.0f, 0.344732f,
    -0.411725f,   0.0f, 0.343405f, -0.421194f,   0.0f, 0.342962f, -0.46692f,     0.0f, 0.342962f,
    -0.46692f,    0.0f, 0.450602f, -0.4392f,     0.0f, 0.450602f, -0.4392f,      0.0f, 0.415502f,
    -0.421889f,   0.0f, 0.415502f, -0.411053f,   0.0f, 0.414689f, -0.402154f,    0.0f, 0.412251f,
    -0.394594f,   0.0f, 0.408223f, -0.387776f,   0.0f, 0.40264f,  -0.383613f,    0.0f, 0.397395f,
    -0.380535f,   0.0f, 0.391046f, -0.378634f,   0.0f, 0.384064f, -0.378f,       0.0f, 0.37692f,
    -0.407098f,   0.0f, 0.381884f, -0.407994f,   0.0f, 0.385411f, -0.409558f,    0.0f, 0.388366f,
    -0.411863f,   0.0f, 0.390876f, -0.415343f,   0.0f, 0.393018f, -0.419565f,    0.0f, 0.394304f,
    -0.42478f,    0.0f, 0.394948f, -0.431243f,   0.0f, 0.395162f, -0.4392f,      0.0f, 0.395162f,
    -0.4392f,     0.0f, 0.363302f, -0.434427f,   0.0f, 0.363302f, -0.423435f,    0.0f, 0.363481f,
    -0.419258f,   0.0f, 0.364043f, -0.414973f,   0.0f, 0.365375f, -0.411918f,    0.0f, 0.367151f,
    -0.40926f,    0.0f, 0.36991f,  -0.407415f,   0.0f, 0.373472f, -0.4068f,      0.0f, 0.37766f,
    -0.298234f,   0.0f, 0.3799f,   -0.299237f,   0.0f, 0.383051f, -0.300964f,    0.0f, 0.385628f,
    -0.303469f,   0.0f, 0.38797f,  -0.306868f,   0.0f, 0.389855f, -0.310989f,    0.0f, 0.390915f,
    -0.316015f,   0.0f, 0.3914f,   -0.322127f,   0.0f, 0.391562f, -0.33066f,     0.0f, 0.391562f,
    -0.33066f,    0.0f, 0.362762f, -0.320608f,   0.0f, 0.362762f, -0.311858f,    0.0f, 0.363014f,
    -0.308333f,   0.0f, 0.363489f, -0.305277f,   0.0f, 0.364413f, -0.301824f,    0.0f, 0.366371f,
    -0.299564f,   0.0f, 0.36894f,  -0.298316f,   0.0f, 0.3721f,   -0.2979f,      0.0f, 0.375834f,
    -0.290517f,   0.0f, 0.404528f, -0.281396f,   0.0f, 0.398903f, -0.274653f,    0.0f, 0.392012f,
    -0.270488f,   0.0f, 0.383385f, -0.2691f,     0.0f, 0.372552f, -0.269997f,    0.0f, 0.364603f,
    -0.272687f,   0.0f, 0.358119f, -0.276899f,   0.0f, 0.352901f, -0.282361f,    0.0f, 0.34875f,
    -0.288594f,   0.0f, 0.345766f, -0.29526f,    0.0f, 0.344048f, -0.302815f,    0.0f, 0.343233f,
    -0.311712f,   0.0f, 0.342962f, -0.35838f,    0.0f, 0.342962f, -0.35838f,     0.0f, 0.450602f,
    -0.33066f,    0.0f, 0.450602f, -0.33066f,    0.0f, 0.411182f, -0.31788f,     0.0f, 0.411182f,
    -0.288554f,   0.0f, 0.450602f, -0.25452f,    0.0f, 0.450602f, -0.15822f,     0.0f, 0.342962f,
    -0.25326f,    0.0f, 0.342962f, -0.25326f,    0.0f, 0.363842f, -0.2196f,      0.0f, 0.363842f,
    -0.2196f,     0.0f, 0.450602f, -0.19188f,    0.0f, 0.450602f, -0.19188f,     0.0f, 0.363842f,
    -0.15822f,    0.0f, 0.363842f, -0.00971994f, 0.0f, 0.429722f, -0.0597599f,   0.0f, 0.429722f,
    -0.0597599f,  0.0f, 0.342962f, -0.0874799f,  0.0f, 0.342962f, -0.0874799f,   0.0f, 0.450602f,
    -0.00971994f, 0.0f, 0.450602f, 0.0856533f,   0.0f, 0.392143f, 0.0769332f,    0.0f, 0.378466f,
    0.0628889f,   0.0f, 0.369793f, 0.04401f,     0.0f, 0.366902f, 0.0253122f,    0.0f, 0.369775f,
    0.0112318f,   0.0f, 0.378394f, 0.00240296f,  0.0f, 0.392053f, -0.000539958f, 0.0f, 0.410049f,
    0.0023847f,   0.0f, 0.427945f, 0.0111586f,   0.0f, 0.441595f, 0.0252208f,    0.0f, 0.45024f,
    0.04401f,     0.0f, 0.453122f, 0.0627993f,   0.0f, 0.45024f,  0.0768615f,    0.0f, 0.441595f,
    0.0856354f,   0.0f, 0.427945f, 0.0885601f,   0.0f, 0.410049f, 0.0539913f,    0.0f, 0.432154f,
    0.051009f,    0.0f, 0.433751f, 0.0476997f,   0.0f, 0.434644f, 0.0442266f,    0.0f, 0.434942f,
    0.0403211f,   0.0f, 0.434617f, 0.0368677f,   0.0f, 0.433643f, 0.0338671f,    0.0f, 0.431965f,
    0.0313201f,   0.0f, 0.429531f, 0.0292166f,   0.0f, 0.426094f, 0.0276933f,    0.0f, 0.421701f,
    0.0267683f,   0.0f, 0.416388f, 0.02646f,     0.0f, 0.410192f, 0.0268137f,    0.0f, 0.403392f,
    0.0278747f,   0.0f, 0.397854f, 0.0295341f,   0.0f, 0.39347f,  0.0316829f,    0.0f, 0.390133f,
    0.0344293f,   0.0f, 0.387607f, 0.0373022f,   0.0f, 0.386092f, 0.0404473f,    0.0f, 0.385334f,
    0.04401f,     0.0f, 0.385082f, 0.0476543f,   0.0f, 0.385389f, 0.0510441f,    0.0f, 0.386308f,
    0.0540718f,   0.0f, 0.387968f, 0.0566297f,   0.0f, 0.390493f, 0.0586962f,    0.0f, 0.393866f,
    0.060255f,    0.0f, 0.398214f, 0.0612338f,   0.0f, 0.403626f, 0.0615601f,    0.0f, 0.410192f,
    0.0612429f,   0.0f, 0.417074f, 0.0602916f,   0.0f, 0.422279f, 0.0587054f,    0.0f, 0.426329f,
    0.0564835f,   0.0f, 0.429747f, 0.153136f,    0.0f, 0.431691f, 0.149365f,     0.0f, 0.433533f,
    0.145376f,    0.0f, 0.434725f, 0.141441f,    0.0f, 0.435122f, 0.137172f,     0.0f, 0.43495f,
    0.134206f,    0.0f, 0.434436f, 0.132052f,    0.0f, 0.43356f,  0.130224f,     0.0f, 0.432304f,
    0.128814f,    0.0f, 0.430824f, 0.128055f,    0.0f, 0.429272f, 0.127729f,     0.0f, 0.427448f,
    0.12762f,     0.0f, 0.425155f, 0.128136f,    0.0f, 0.421697f, 0.129683f,     0.0f, 0.41898f,
    0.132207f,    0.0f, 0.416912f, 0.135653f,    0.0f, 0.415404f, 0.139578f,     0.0f, 0.414455f,
    0.144987f,    0.0f, 0.413633f, 0.15642f,     0.0f, 0.412442f, 0.15642f,      0.0f, 0.429342f,
    0.15642f,     0.0f, 0.450602f, 0.18216f,     0.0f, 0.450602f, 0.18216f,      0.0f, 0.395238f,
    0.179692f,    0.0f, 0.382547f, 0.172288f,    0.0f, 0.37375f,  0.159335f,     0.0f, 0.368614f,
    0.140217f,    0.0f, 0.366902f, 0.130897f,    0.0f, 0.367269f, 0.121596f,     0.0f, 0.368369f,
    0.113596f,    0.0f, 0.369737f, 0.10818f,     0.0f, 0.37091f,  0.10818f,      0.0f, 0.390302f,
    0.110571f,    0.0f, 0.390302f, 0.121073f,    0.0f, 0.38681f,  0.128171f,     0.0f, 0.385109f,
    0.134834f,    0.0f, 0.384542f, 0.144251f,    0.0f, 0.3852f,   0.151059f,     0.0f, 0.387173f,
    0.155187f,    0.0f, 0.39087f,  0.156563f,    0.0f, 0.396698f, 0.156563f,     0.0f, 0.397142f,
    0.145262f,    0.0f, 0.397975f, 0.134359f,    0.0f, 0.39917f,  0.124522f,     0.0f, 0.401016f,
    0.116421f,    0.0f, 0.403805f, 0.109948f,    0.0f, 0.407662f, 0.105138f,     0.0f, 0.412713f,
    0.102155f,    0.0f, 0.419177f, 0.10116f,     0.0f, 0.427269f, 0.103113f,     0.0f, 0.437426f,
    0.108972f,    0.0f, 0.445592f, 0.117724f,    0.0f, 0.450969f, 0.128357f,     0.0f, 0.452762f,
    0.133075f,    0.0f, 0.452555f, 0.137396f,    0.0f, 0.451934f, 0.141447f,     0.0f, 0.450879f,
    0.145353f,    0.0f, 0.449373f, 0.148193f,    0.0f, 0.447836f, 0.151213f,     0.0f, 0.445828f,
    0.15642f,     0.0f, 0.441993f, 0.28512f,     0.0f, 0.338102f, 0.25902f,      0.0f, 0.338102f,
    0.25902f,     0.0f, 0.372578f, 0.254154f,    0.0f, 0.370398f, 0.249415f,     0.0f, 0.368636f,
    0.244079f,    0.0f, 0.36747f,  0.23742f,     0.0f, 0.367082f, 0.230388f,     0.0f, 0.367832f,
    0.223356f,    0.0f, 0.370083f, 0.21685f,     0.0f, 0.373689f, 0.211396f,     0.0f, 0.378506f,
    0.206729f,    0.0f, 0.384788f, 0.203168f,    0.0f, 0.392207f, 0.200912f,     0.0f, 0.400785f,
    0.20016f,     0.0f, 0.410538f, 0.202389f,    0.0f, 0.427926f, 0.209076f,     0.0f, 0.441338f,
    0.219478f,    0.0f, 0.449906f, 0.232853f,    0.0f, 0.452762f, 0.240083f,     0.0f, 0.452121f,
    0.246407f,    0.0f, 0.4502f,   0.252496f,    0.0f, 0.446904f, 0.25902f,      0.0f, 0.442139f,
    0.25902f,     0.0f, 0.450602f, 0.28512f,     0.0f, 0.450602f, 0.255751f,     0.0f, 0.430083f,
    0.252013f,    0.0f, 0.431626f, 0.248148f,    0.0f, 0.432628f, 0.244499f,     0.0f, 0.432962f,
    0.236642f,    0.0f, 0.431617f, 0.231278f,    0.0f, 0.427582f, 0.228189f,     0.0f, 0.420567f,
    0.22716f,     0.0f, 0.410285f, 0.228443f,    0.0f, 0.400182f, 0.23229f,      0.0f, 0.392553f,
    0.238702f,    0.0f, 0.38776f,  0.247677f,    0.0f, 0.386162f, 0.250332f,     0.0f, 0.386289f,
    0.25324f,     0.0f, 0.386668f, 0.256203f,    0.0f, 0.387336f, 0.25902f,      0.0f, 0.388328f,
    0.25902f,     0.0f, 0.428124f, 0.3897f,      0.0f, 0.405684f, 0.387201f,     0.0f, 0.389101f,
    0.379706f,    0.0f, 0.376905f, 0.367249f,    0.0f, 0.369403f, 0.349867f,     0.0f, 0.366902f,
    0.330647f,    0.0f, 0.369838f, 0.316008f,    0.0f, 0.378647f, 0.306747f,     0.0f, 0.392478f,
    0.30366f,     0.0f, 0.410482f, 0.306922f,    0.0f, 0.42846f,  0.316709f,     0.0f, 0.441776f,
    0.332621f,    0.0f, 0.450016f, 0.35426f,     0.0f, 0.452762f, 0.36334f,      0.0f, 0.452363f,
    0.371586f,    0.0f, 0.451166f, 0.379669f,    0.0f, 0.44908f,  0.38826f,      0.0f, 0.446015f,
    0.38826f,     0.0f, 0.425042f, 0.385346f,    0.0f, 0.425042f, 0.38001f,      0.0f, 0.428407f,
    0.373035f,    0.0f, 0.43155f,  0.365112f,    0.0f, 0.433824f, 0.356934f,     0.0f, 0.434582f,
    0.345414f,    0.0f, 0.433308f, 0.337081f,    0.0f, 0.429486f, 0.331881f,     0.0f, 0.423262f,
    0.32976f,     0.0f, 0.414782f, 0.3897f,      0.0f, 0.414782f, 0.329687f,     0.0f, 0.399482f,
    0.33134f,     0.0f, 0.392068f, 0.335133f,    0.0f, 0.386999f, 0.34067f,      0.0f, 0.384076f,
    0.347552f,    0.0f, 0.383102f, 0.354614f,    0.0f, 0.38413f,  0.359535f,     0.0f, 0.387215f,
    0.362475f,    0.0f, 0.392339f, 0.3636f,      0.0f, 0.399482f, 0.46692f,      0.0f, 0.369352f,
    0.465513f,    0.0f, 0.369224f, 0.46389f,     0.0f, 0.369134f, 0.460786f,     0.0f, 0.369062f,
    0.455195f,    0.0f, 0.369677f, 0.449097f,    0.0f, 0.37152f,  0.442188f,     0.0f, 0.375208f,
    0.43416f,     0.0f, 0.381355f, 0.43416f,     0.0f, 0.369422f, 0.40806f,      0.0f, 0.369422f,
    0.40806f,     0.0f, 0.450602f, 0.43416f,     0.0f, 0.450602f, 0.43416f,      0.0f, 0.396186f,
    0.438905f,    0.0f, 0.394703f, 0.443325f,    0.0f, 0.393726f, 0.447906f,     0.0f, 0.393183f,
    0.453139f,    0.0f, 0.393002f, 0.455898f,    0.0f, 0.393069f, 0.459271f,     0.0f, 0.393272f,
    0.462446f,    0.0f, 0.393609f, 0.464611f,    0.0f, 0.394082f, 0.46692f,      0.0f, 0.394082f,
};

int faces[] = {
    21,  22,  1,   38,  21,  1,   37,  38,  1,   0,   1,   22,  20,  0,   22,  19,  20,  22,  18,  19,  22,  17,  18,
    22,  16,  17,  22,  16,  22,  23,  15,  16,  23,  15,  23,  24,  14,  15,  24,  13,  14,  24,  13,  24,  25,  37,
    1,   2,   36,  37,  2,   36,  2,   3,   36,  3,   4,   35,  36,  4,   35,  4,   5,   34,  35,  5,   34,  5,   6,
    33,  34,  6,   33,  6,   7,   32,  33,  7,   12,  13,  25,  12,  25,  26,  12,  26,  27,  11,  12,  27,  11,  27,
    28,  11,  28,  29,  32,  7,   8,   31,  32,  8,   30,  31,  8,   30,  8,   9,   29,  30,  9,   11,  29,  9,   10,
    11,  9,   75,  76,  57,  74,  75,  57,  57,  40,  41,  74,  57,  41,  74,  41,  42,  74,  42,  43,  74,  43,  44,
    74,  44,  45,  40,  57,  58,  74,  45,  46,  73,  74,  46,  73,  46,  47,  71,  72,  73,  70,  71,  73,  70,  73,
    47,  70,  47,  48,  69,  70,  48,  69,  48,  49,  69,  49,  50,  68,  69,  50,  68,  50,  51,  68,  51,  52,  67,
    68,  52,  40,  58,  59,  39,  40,  59,  39,  59,  60,  39,  60,  61,  56,  39,  61,  55,  56,  61,  55,  61,  62,
    55,  62,  63,  55,  63,  64,  54,  55,  64,  54,  64,  65,  54,  65,  66,  53,  54,  66,  53,  66,  67,  53,  67,
    52,  83,  84,  77,  83,  77,  78,  81,  82,  83,  80,  81,  83,  80,  83,  78,  79,  80,  78,  89,  90,  85,  89,
    85,  86,  88,  89,  86,  88,  86,  87,  92,  126, 127, 92,  127, 128, 126, 92,  93,  92,  128, 129, 126, 93,  94,
    92,  129, 130, 126, 94,  95,  125, 126, 95,  124, 125, 95,  123, 124, 95,  123, 95,  96,  122, 123, 96,  121, 122,
    96,  121, 96,  97,  120, 121, 97,  120, 97,  98,  119, 120, 98,  118, 119, 98,  118, 98,  99,  117, 118, 99,  116,
    117, 99,  116, 99,  100, 115, 116, 100, 115, 100, 101, 114, 115, 101, 113, 114, 101, 113, 101, 102, 112, 113, 102,
    111, 112, 102, 110, 111, 102, 110, 102, 103, 109, 110, 103, 108, 109, 103, 107, 108, 103, 107, 103, 104, 138, 107,
    104, 137, 138, 104, 137, 104, 105, 136, 137, 105, 136, 105, 106, 135, 136, 106, 134, 135, 106, 134, 106, 91,  133,
    134, 91,  132, 133, 91,  132, 91,  92,  131, 132, 92,  131, 92,  130, 139, 140, 160, 158, 139, 160, 158, 160, 161,
    157, 158, 161, 169, 170, 171, 169, 171, 172, 168, 169, 172, 167, 168, 172, 167, 172, 173, 166, 167, 173, 166, 173,
    174, 165, 166, 174, 165, 174, 175, 164, 165, 175, 164, 175, 176, 198, 159, 160, 198, 160, 140, 197, 198, 140, 197,
    140, 141, 163, 164, 176, 163, 176, 177, 162, 163, 177, 161, 162, 177, 161, 177, 178, 161, 178, 179, 157, 161, 179,
    157, 179, 180, 156, 157, 180, 156, 180, 181, 155, 156, 181, 154, 155, 181, 154, 181, 182, 153, 154, 182, 196, 197,
    141, 196, 141, 142, 195, 196, 142, 194, 195, 142, 194, 142, 143, 193, 194, 143, 153, 182, 183, 152, 153, 183, 192,
    193, 143, 192, 143, 144, 191, 192, 144, 191, 144, 145, 190, 191, 145, 190, 145, 146, 189, 190, 146, 189, 146, 147,
    188, 189, 147, 188, 147, 148, 187, 188, 148, 187, 148, 149, 186, 187, 149, 186, 149, 150, 185, 186, 150, 185, 150,
    151, 184, 185, 151, 183, 184, 151, 152, 183, 151, 199, 237, 238, 199, 238, 239, 223, 199, 239, 223, 239, 240, 221,
    222, 223, 221, 223, 240, 221, 240, 224, 221, 224, 225, 199, 200, 201, 237, 199, 201, 237, 201, 202, 236, 237, 202,
    220, 221, 225, 220, 225, 226, 236, 202, 203, 235, 236, 203, 235, 203, 204, 234, 235, 204, 234, 204, 205, 234, 205,
    206, 234, 206, 207, 233, 234, 207, 233, 207, 208, 233, 208, 209, 233, 209, 210, 232, 233, 210, 232, 210, 211, 232,
    211, 212, 231, 232, 212, 231, 212, 213, 231, 213, 214, 230, 231, 214, 230, 214, 215, 229, 230, 215, 229, 215, 216,
    229, 216, 217, 228, 229, 217, 228, 217, 218, 227, 228, 218, 227, 218, 219, 227, 219, 220, 227, 220, 226, 277, 269,
    241, 277, 241, 242, 276, 277, 242, 276, 242, 243, 276, 243, 244, 275, 276, 244, 275, 244, 245, 274, 275, 245, 273,
    274, 245, 273, 245, 246, 272, 273, 246, 271, 272, 246, 271, 246, 247, 270, 271, 247, 270, 247, 248, 269, 270, 248,
    269, 248, 249, 267, 268, 241, 267, 241, 269, 267, 269, 249, 267, 249, 250, 266, 267, 250, 266, 250, 251, 266, 251,
    252, 265, 266, 252, 264, 265, 252, 264, 252, 253, 263, 264, 253, 263, 253, 254, 262, 263, 254, 262, 254, 255, 261,
    262, 255, 261, 255, 256, 257, 258, 259, 257, 259, 260, 256, 257, 260, 261, 256, 260, 298, 299, 278, 297, 298, 278,
    297, 278, 279, 297, 279, 280, 296, 297, 280, 296, 280, 281, 296, 281, 282, 295, 296, 282, 295, 282, 283, 294, 295,
    283, 294, 283, 284, 293, 294, 284, 293, 284, 285, 292, 293, 285, 291, 292, 285, 290, 291, 285, 288, 289, 290, 287,
    288, 290, 287, 290, 285, 286, 287, 285,
};

trimesh3 g_prtLoaderIconMesh;
bool g_isPRTLoaderIconMeshBuilt = false;
} // namespace

const frantic::geometry::trimesh3& get_prt_loader_icon_mesh() {
    if( !g_isPRTLoaderIconMeshBuilt ) {
        build_icon_mesh( vertices, sizeof( vertices ) / ( sizeof( float ) * 3 ), faces,
                         sizeof( faces ) / ( sizeof( int ) * 3 ), g_prtLoaderIconMesh );
        g_isPRTLoaderIconMeshBuilt = true;
    }

    return g_prtLoaderIconMesh;
}
